<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <input type="text" name="" id="num" value="80">
    <button id="btn1">华氏度</button>
    <button id="btn2">摄氏度</button>
    <input type="text" name="" id="num1">
    <input type="text" name="" id="num2">

    <script>
        document.getElementById("btn1").onclick = function() {
            var _num1 = parseInt(document.getElementById("num").value);

            document.getElementById("num1").value = _num1;
        }
        document.getElementById("btn2").onclick = function() {
            var _num1 = parseFloat(document.getElementById("num").value);
            a = 5 / 9.0 * (_num1 - 32);
            document.getElementById("num2").value = a.toFixed(3);
            // alert(a.toFixed(3));
        }
    </script>
</body>

</html>